<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item>数据填报</el-breadcrumb-item>
      <el-breadcrumb-item>表格操作</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片区域 -->
    <el-card>
      <!-- 施工主管下载表格 -->
      <div v-if="roleName == '施工主管'">
        <div class="excel">
          <el-col class="title" style="margin-right: 25px">进度表</el-col>
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="warning"
              @click="DownloadProgressExcel"
              >下载表格</el-button
            >
          </el-col>
          <el-col :span="7" style="text-align: center">
            <el-button size="small" type="danger" @click="DownloadProgressModel"
              >下载模板</el-button
            >
          </el-col>
        </div>
      </div>
      <!-- 试验主管下载表格 -->
      <div v-if="roleName == '试验主管'">
        <div class="excel">
          <el-col class="title" style="margin-right: 25px">试验检测表</el-col>
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="warning"
              @click="DownloadExperimentExcel"
              >下载表格</el-button
            >
          </el-col>
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="danger"
              @click="DownloadExperimentModel"
              >下载模板</el-button
            >
          </el-col>
        </div>
      </div>

      <!-- 试验主管下载不及格表格 -->
      <div v-if="roleName == '试验主管'">
        <div class="excel">
          <el-col class="title" style="margin-right: 25px"
            >试验检测不合格表</el-col
          >
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="warning"
              @click="DownloadExperimentExcelQus"
              >下载表格</el-button
            >
          </el-col>
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="danger"
              @click="DownloadExperimentModelQus"
              >下载模板</el-button
            >
          </el-col>
        </div>
      </div>

      <!-- 资料主管下载表格 -->
      <div v-if="roleName == '资料主管'">
        <div class="excel">
          <el-col class="title" style="margin-right: 25px">资料表</el-col>
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="warning"
              @click="DownloadDocumentExcel"
              >下载表格</el-button
            >
          </el-col>
          <el-col :span="7" style="text-align: center">
            <el-button size="small" type="danger" @click="DownloadDocumentModel"
              >下载模板</el-button
            >
          </el-col>
        </div>
      </div>

      <!-- 资料主管下载问题表格 -->
      <div v-if="roleName == '资料主管'">
        <div class="excel">
          <el-col class="title" style="margin-right: 25px">资料不合格表</el-col>
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="warning"
              @click="DownloadDocumentExcelQus"
              >下载表格</el-button
            >
          </el-col>
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="danger"
              @click="DownloadDocumentModelQus"
              >下载模板</el-button
            >
          </el-col>
        </div>
      </div>

      <!-- 合约主管下载表格 -->
      <div v-if="roleName == '合约主管'">
        <div class="excel">
          <el-col class="title" style="margin-right: 25px">基础清单表</el-col>
          <el-col :span="7" style="text-align: center">
            <el-button
              size="small"
              type="warning"
              @click="DownloadBaseListExcel"
              >下载表格</el-button
            >
          </el-col>
          <el-col :span="7" style="text-align: center">
            <el-button size="small" type="danger" @click="DownloadBaseListModel"
              >下载模板</el-button
            >
          </el-col>
        </div>
        <div class="excel">
          <el-col class="title" style="margin-right: 25px">甩项工程量</el-col>
          <el-col :span="7" style="text-align: center">
            <el-button size="small" type="warning" @click="DownloadJiltExcel"
              >下载表格</el-button
            >
          </el-col>
          <el-col :span="7" style="text-align: center">
            <el-button size="small" type="danger" @click="DownloadJiltModel"
              >下载模板</el-button
            >
          </el-col>
        </div>
      </div>
      <!-- 基础清单表 -->
      <div v-if="roleName == '合约员'">
        <!-- <div v-if="arr.indexOf('baseList') > -1">       -->
        <div class="excel">
          <span class="title">基础清单表</span>
          <el-row>
            <el-col :span="10">
              <el-upload
                ref="uploadBaseList"
                accept=".xls, .xlsx"
                action
                :limit="1"
                :auto-upload="false"
                :on-change="BaseListChange"
                :on-exceed="OnExceed"
                :on-remove="BaseListRemove"
                :file-list="fileListBase"
              >
                <template #trigger>
                  <el-button size="small" type="primary">选择表格</el-button>
                </template>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="info"
                  @click="checkBaseList"
                  >检查表格
                </el-button>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="uploadBaseList"
                >
                  确认上传</el-button
                >
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传xls,xlsx格式的excel文件
                  </div>
                  <div class="el-upload__tip" style="font-size: 15px">
                    {{ currentTime }}
                  </div>
                </template>
              </el-upload>
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="warning"
                @click="DownloadBaseListExcel"
                >下载表格</el-button
              >
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="danger"
                @click="DownloadBaseListModel"
                >下载模板</el-button
              >
            </el-col>
          </el-row>
        </div>
        <!-- 在线查看、编辑excel -->
        <div
          class="excelData"
          style="margin-bottom: 12px"
          v-show="this.excelTableBase"
        >
          <el-button
            type="warning"
            plain
            @click="closeCheckDataBase"
            style="margin-top: 10px"
            >关闭</el-button
          >
          <el-table
            :data="excelDataBase"
            border
            stripe
            style="height: 300px; width: 100%"
            max-height="300px"
          >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column prop="项目编号" label="项目编号"></el-table-column>
            <el-table-column
              prop="项目名称"
              label="项目名称"
              min-width="150px"
            ></el-table-column>
            <el-table-column prop="项目简称" label="项目简称"></el-table-column>
            <el-table-column prop="计量单位" label="计量单位"></el-table-column>
            <el-table-column
              prop="清单工程量"
              label="清单工程量"
            ></el-table-column>
            <el-table-column prop="综合单价" label="综合单价"></el-table-column>
            <el-table-column prop="合价" label="合价"></el-table-column>
            <el-table-column prop="工程名称" label="工程名称"></el-table-column>
            <el-table-column prop="分部工程" label="分部工程"></el-table-column>
            <el-table-column prop="分项工程" label="分项工程"></el-table-column>
            <el-table-column
              prop="所属项目部"
              label="所属项目部"
            ></el-table-column>
            <el-table-column prop="所属公司" label="所属公司"></el-table-column>
            <el-table-column prop="主材名称" label="主材名称"></el-table-column>
            <el-table-column prop="主材单位" label="主材单位"></el-table-column>
            <el-table-column prop="换算系数" label="换算系数"></el-table-column>
            <el-table-column prop="主材数量" label="主材数量"></el-table-column>
          </el-table>
        </div>
        <!-- 甩项工程量 -->
        <!-- <div v-if="arr.indexOf('Jilt') > -1"> -->
        <div class="excel">
          <span class="title">甩项工程量</span>
          <el-row>
            <el-col :span="10">
              <el-upload
                ref="uploadJilt"
                accept=".xls, .xlsx"
                action
                :limit="1"
                :auto-upload="false"
                :on-change="JiltChange"
                :on-exceed="OnExceed"
                :on-remove="JiltRemove"
                :file-list="fileListJilt"
              >
                <template #trigger>
                  <el-button size="small" type="primary">选择表格</el-button>
                </template>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="info"
                  @click="checkJilt"
                  >检查表格
                </el-button>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="uploadJilt"
                  >确认上传
                </el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传xls,xlsx格式的excel文件
                  </div>
                  <div class="el-upload__tip" style="font-size: 15px">
                    {{ currentTime }}
                  </div>
                </template>
              </el-upload>
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button size="small" type="warning" @click="DownloadJiltExcel"
                >下载表格</el-button
              >
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button size="small" type="danger" @click="DownloadJiltModel"
                >下载模板</el-button
              >
            </el-col>
          </el-row>
        </div>
        <!-- 在线查看、编辑excel -->
        <div
          class="excelData"
          style="margin-bottom: 12px"
          v-show="this.excelTableJilt"
        >
          <el-button
            type="warning"
            plain
            @click="closeCheckJilt"
            style="margin-top: 10px"
            >关闭</el-button
          >
          <el-table
            :data="excelDataJilt"
            border
            stripe
            style="height: 300px; width: 100%"
            max-height="300px"
          >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column prop="项目编号" label="项目编号"></el-table-column>
            <el-table-column prop="项目名称" label="项目名称"></el-table-column>
            <el-table-column prop="项目简称" label="项目简称"></el-table-column>
            <el-table-column prop="计量单位" label="计量单位"></el-table-column>
            <el-table-column
              prop="甩项工程量"
              label="甩项工程量"
            ></el-table-column>
            <el-table-column prop="综合单价" label="综合单价"></el-table-column>
            <el-table-column prop="合价" label="合价"></el-table-column>
            <el-table-column prop="工程名称" label="工程名称"></el-table-column>
            <el-table-column prop="分部工程" label="分部工程"></el-table-column>
            <el-table-column prop="分项工程" label="分项工程"></el-table-column>
            <el-table-column
              prop="所属项目部"
              label="所属项目部"
            ></el-table-column>
            <el-table-column prop="所属公司" label="所属公司"></el-table-column>
            <el-table-column prop="甩项原因" label="甩项原因"></el-table-column>
          </el-table>
        </div>
        <!-- 参数表 -->
        <div class="excel">
          <span class="title">参数表下载</span>
          <el-button
                size="small"
                type="danger"
                @click="Downloadparameter"
                >下载参数表</el-button
              >
        </div>
      </div>

      <!-- 进度表 -->
      <div v-if="roleName == '施工员' || roleName == '超级管理员' ">
        <!-- <div v-if="arr.indexOf('progress') > -1"> -->
        <div class="excel">
          <span class="title">进度表</span>
          <el-row>
            <el-col :span="10">
              <el-upload
                ref="uploadProgress"
                accept=".xls, .xlsx"
                action
                :limit="1"
                :auto-upload="false"
                :on-change="ProgressChange"
                :on-exceed="OnExceed"
                :on-remove="ProgressRemove"
                :file-list="fileListPro"
              >
                <template #trigger>
                  <el-button size="small" type="primary">选择表格</el-button>
                </template>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="info"
                  @click="checkProgress"
                  >检查表格
                </el-button>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="uploadProgress"
                >
                  确认上传</el-button
                >
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传xls,xlsx格式的excel文件
                  </div>
                  <div class="el-upload__tip" style="font-size: 15px">
                    {{ currentTime }}
                  </div>
                </template>
              </el-upload>
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="warning"
                @click="DownloadProgressExcel"
                >下载表格</el-button
              >
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="danger"
                @click="DownloadProgressModel"
                >下载模板</el-button
              >
            </el-col>
          </el-row>
        </div>
        <!-- 在线查看、编辑excel -->
        <div
          class="excelData"
          style="margin-bottom: 12px"
          v-show="this.excelTablePro"
        >
          <el-button
            type="warning"
            plain
            @click="closeCheckDataPro"
            style="margin"
            >关闭</el-button
          >
          <el-table
            :data="excelDataPro"
            border
            stripe
            style="height: 300px; width: 100%"
            max-height="300px"
          >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column
              prop="进度单编号"
              label="进度单编号"
            ></el-table-column>
            <el-table-column
              prop="日期和时间"
              label="日期和时间"
            ></el-table-column>
            <el-table-column prop="起桩号" label="起桩号"></el-table-column>
            <el-table-column
              prop="止桩号"
              label="止桩号"
              min-width="150px"
            ></el-table-column>
            <el-table-column
              prop="本次完成工程量"
              label="本次完成工程量"
            ></el-table-column>
            <el-table-column
              prop="本次完成金额"
              label="本次完成金额"
            ></el-table-column>
            <el-table-column
              prop="累计完成工程量"
              label="累计完成工程量"
            ></el-table-column>
            <el-table-column
              prop="累计完成金额"
              label="累计完成金额"
            ></el-table-column>
            <el-table-column
              prop="累计完成百分比"
              label="累计完成百分比"
            ></el-table-column>
            <el-table-column prop="项目编号" label="项目编号"></el-table-column>
          </el-table>
        </div>
          <!-- 参数表 -->
        <div class="excel">
          <span class="title">参数表下载</span>
          <el-button
                size="small"
                type="danger"
                @click="Downloadparameter"
                >下载参数表</el-button
              >
        </div>
      </div>

      <!-- 试验检测表 -->
      <div v-if="roleName == '试验员'">
        <!-- <div v-if="arr.indexOf('experiment') > -1"> -->
        <div class="excel">
          <span class="title">试验检测表</span>
          <el-row>
            <el-col :span="10">
              <el-upload
                ref="uploadExperiment"
                accept=".xls, .xlsx"
                action
                :limit="1"
                :auto-upload="false"
                :on-change="ExperimentChange"
                :on-exceed="OnExceed"
                :on-remove="ExperimentRemove"
                :file-list="fileListExp"
              >
                <template #trigger>
                  <el-button size="small" type="primary">选择表格</el-button>
                </template>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="info"
                  @click="checkExperiment"
                >
                  检查表格</el-button
                >
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="uploadExperiment"
                  >确认上传
                </el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传xls,xlsx格式的excel文件
                  </div>
                  <div class="el-upload__tip" style="font-size: 15px">
                    {{ currentTime }}
                  </div>
                </template>
              </el-upload>
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="warning"
                @click="DownloadExperimentExcel"
                >下载表格</el-button
              >
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="danger"
                @click="DownloadExperimentModel"
                >下载模板</el-button
              >
            </el-col>
          </el-row>
        </div>
        <!-- 在线查看、编辑excel -->
        <div
          class="excelData"
          style="margin-bottom: 12px"
          v-show="this.excelTableExp"
        >
          <el-button
            type="warning"
            plain
            @click="closeCheckDataExp"
            style="margin-top: 10px"
            >关闭</el-button
          >
          <el-table
            :data="excelDataExp"
            border
            stripe
            style="height: 650px; width: 100%"
            max-height="650px"
          >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column prop="工程名称" label="工程名称"></el-table-column>
            <el-table-column
              prop="材料及实体名称"
              label="材料及实体名称"
              min-width="150px"
            ></el-table-column>
            <el-table-column prop="检测项目" label="检测项目"></el-table-column>
            <el-table-column prop="检测频率" label="检测频率"></el-table-column>
            <el-table-column prop="说明" label="说明"></el-table-column>
            <el-table-column
              prop="工程量单位"
              label="工程量单位"
            ></el-table-column>
            <el-table-column
              prop="清单工程量"
              label="清单工程量"
            ></el-table-column>
            <el-table-column
              prop="现场进度工程量"
              label="现场进度工程量"
            ></el-table-column>
            <el-table-column prop="检测单位" label="检测单位"></el-table-column>
            <el-table-column prop="检测系数" label="检测系数"></el-table-column>
            <el-table-column
              prop="实际检测数量"
              label="实际检测数量"
            ></el-table-column>
            <el-table-column
              prop="已取检测报告数量"
              label="已取检测报告数量"
            ></el-table-column>
            <el-table-column
              prop="检测合格数量"
              label="检测合格数量"
            ></el-table-column>
          </el-table>
        </div>
      </div>

      <!-- 试验检测不合格表 -->
      <div v-if="roleName == '试验员'">
        <!-- <div v-if="arr.indexOf('experiment') > -1"> -->
        <div class="excel">
          <span class="title">试验检测不合格表</span>
          <el-row>
            <el-col :span="10">
              <el-upload
                ref="uploadExperimentQus"
                accept=".xls, .xlsx"
                action
                :limit="1"
                :auto-upload="false"
                :on-change="ExperimentChangeQus"
                :on-exceed="OnExceed"
                :on-remove="ExperimentRemoveQus"
                :file-list="fileListExpQus"
              >
                <template #trigger>
                  <el-button size="small" type="primary">选择表格</el-button>
                </template>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="info"
                  @click="checkExperimentQus"
                  >检查表格
                </el-button>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="uploadExperimentQus"
                  >确认上传
                </el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传xls,xlsx格式的excel文件
                  </div>
                  <div class="el-upload__tip" style="font-size: 15px">
                    {{ currentTimeQus }}
                  </div>
                </template>
              </el-upload>
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="warning"
                @click="DownloadExperimentExcelQus"
                >下载表格</el-button
              >
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="danger"
                @click="DownloadExperimentModelQus"
                >下载模板</el-button
              >
            </el-col>
          </el-row>
        </div>
        <!-- 在线查看、编辑excel -->
        <div
          class="excelData"
          style="margin-bottom: 12px"
          v-show="this.excelTableExpQus"
        >
          <el-button
            type="warning"
            plain
            @click="closeCheckDataExpQus"
            style="margin-top: 10px"
            >关闭</el-button
          >
          <el-table
            :data="excelDataExpQus"
            border
            stripe
            style="height: 650px; width: 100%"
            max-height="650px"
          >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column prop="工程名称" label="工程名称"></el-table-column>
            <el-table-column
              prop="委托单编号"
              label="委托单编号"
              min-width="150px"
            ></el-table-column>
            <el-table-column
              prop="检测报告编号"
              label="检测报告编号"
            ></el-table-column>
            <el-table-column
              prop="材料及实体名称"
              label="材料及实体名称"
            ></el-table-column>
            <el-table-column prop="检测项目" label="检测项目"></el-table-column>
            <el-table-column prop="涉及桩号" label="涉及桩号"></el-table-column>
            <el-table-column
              prop="不合格指标"
              label="不合格指标"
            ></el-table-column>
            <el-table-column
              prop="不合格原因"
              label="不合格原因"
            ></el-table-column>
            <el-table-column
              prop="是否已重新检测"
              label="是否已重新检测"
            ></el-table-column>
            <el-table-column
              prop="重新检测报告是否已取"
              label="重新检测报告是否已取"
            ></el-table-column>
            <el-table-column prop="审核状态" label="审核状态"></el-table-column>
            <el-table-column
              prop="所属项目部"
              label="所属项目部"
            ></el-table-column>
            <el-table-column prop="所属公司" label="所属公司"></el-table-column>
          </el-table>
        </div>
      </div>

      <div v-if="roleName == '技术负责人'">
        <!-- <div v-if="arr.indexOf('experiment') > -1"> -->
        <div class="excel">
          <span class="title">施工计划表</span>
          <el-row>
            <el-col :span="10">
              <el-upload
                ref="uploadPlan"
                accept=".xls, .xlsx"
                action
                :limit="1"
                :auto-upload="false"
                :on-change="PlanChange"
                :on-exceed="OnExceed"
                :on-remove="PlamRemove"
                :file-list="fileListPlan"
              >
                <template #trigger>
                  <el-button size="small" type="primary">选择表格</el-button>
                </template>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="info"
                  @click="checkPlan"
                  >检查表格
                </el-button>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="uploadPlan"
                  >确认上传
                </el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传xls,xlsx格式的excel文件
                  </div>
                  <div class="el-upload__tip" style="font-size: 15px">
                    {{ currentTime }}
                  </div>
                </template>
              </el-upload>
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button size="small" type="warning" @click="DownloadPlanExcel"
                >下载表格</el-button
              >
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button size="small" type="danger" @click="DownloadPlanModel"
                >下载模板表</el-button
              >
            </el-col>
          </el-row>
        </div>
        <!-- 在线查看、编辑excel -->
        <div
          class="excelData"
          style="margin-bottom: 12px"
          v-show="this.excelTablePlan"
        >
          <el-button
            type="warning"
            plain
            @click="closeCheckDataPlan"
            style="margin-top: 10px"
            >关闭</el-button
          >
          <el-table
            :data="excelDataPlan"
            border
            stripe
            style="height: 650px; width: 100%"
            max-height="650px"
          >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column prop="项目编号" label="项目编号"></el-table-column>
            <el-table-column prop="项目名称" label="项目名称"></el-table-column>
            <el-table-column prop="计量单位" label="计量单位"></el-table-column>
            <el-table-column
              prop="剩余工程量"
              label="剩余工程量"
            ></el-table-column>
            <el-table-column
              prop="已完成工程量"
              label="已完成工程量"
            ></el-table-column>
            <el-table-column
              prop="该月计划完成工程量"
              label="该月计划完成工程量"
            ></el-table-column>
            <el-table-column
              prop="计划开始时间"
              label="计划开始时间"
            ></el-table-column>
            <el-table-column
              prop="计划结束时间"
              label="计划结束时间"
            ></el-table-column>
          </el-table>
        </div>
      </div>
      <!-- 资料表 -->
      <div v-if="roleName == '资料员'">
        <!-- <div v-if="arr.indexOf('document') > -1"> -->
        <div class="excel">
          <span class="title">资料表</span>
          <el-row>
            <el-col :span="10">
              <el-upload
                ref="uploadDocument"
                accept=".xls, .xlsx"
                action
                :limit="1"
                :auto-upload="false"
                :on-change="DocumentChange"
                :on-exceed="OnExceed"
                :on-remove="DocumentRemove"
                :file-list="fileListDoc"
              >
                <template #trigger>
                  <el-button size="small" type="primary">选择表格</el-button>
                </template>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="info"
                  @click="checkDocument"
                  >检查表格
                </el-button>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="UploadDocument"
                >
                  确认上传</el-button
                >
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传xls,xlsx格式的excel文件
                  </div>
                  <div class="el-upload__tip" style="font-size: 20px">
                    {{ currentTime }}
                  </div>
                </template>
              </el-upload>
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="warning"
                @click="DownloadDocumentExcel"
                >下载表格</el-button
              >
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="danger"
                @click="DownloadDocumentModel"
                >下载模板</el-button
              >
            </el-col>
          </el-row>
        </div>
        <!-- 在线查看、编辑excel -->
        <div
          class="excelData"
          style="margin-bottom: 12px"
          v-show="this.excelTableDoc"
        >
          <el-button
            type="warning"
            plain
            @click="closeCheckDataDoc"
            style="margin-top: 10px"
            >关闭</el-button
          >
          <el-table
            :data="excelDataDoc"
            border
            stripe
            style="height: 300px; width: 100%"
            max-height="300px"
          >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column
              prop="册数"
              label="册数"
              min-width="150px"
            ></el-table-column>
            <el-table-column
              prop="文件材料名称"
              label="文件材料名称"
            ></el-table-column>
            <el-table-column prop="资料说明" label="资料说明"></el-table-column>
            <el-table-column
              prop="资料完成情况说明"
              label="资料完成情况说明"
            ></el-table-column>
            <el-table-column prop="总数" label="总数"></el-table-column>
            <el-table-column prop="编制数" label="编制数"></el-table-column>
            <el-table-column
              prop="监理签认数"
              label="监理签认数"
            ></el-table-column>
            <el-table-column
              prop="设计签认数"
              label="设计签认数"
            ></el-table-column>
            <el-table-column
              prop="建设单位签认数"
              label="建设单位签认数"
            ></el-table-column>
            <el-table-column
              prop="存档原件数"
              label="存档原件数"
            ></el-table-column>
            <el-table-column
              prop="存档复印件数"
              label="存档复印件数"
            ></el-table-column>
            <el-table-column prop="审核状态" label="审核状态"></el-table-column>
          </el-table>
        </div>
      </div>

      <!-- 资料问题表 -->
      <div v-if="roleName == '资料员'">
        <!-- <div v-if="arr.indexOf('document') > -1"> -->
        <div class="excel">
          <span class="title">资料问题表</span>
          <el-row>
            <el-col :span="10">
              <el-upload
                ref="uploadDocumentQus"
                accept=".xls, .xlsx"
                action
                :limit="1"
                :auto-upload="false"
                :on-change="DocumentChangeQus"
                :on-exceed="OnExceed"
                :on-remove="DocumentRemoveQus"
                :file-list="fileListDocQus"
              >
                <template #trigger>
                  <el-button size="small" type="primary">选择表格</el-button>
                </template>
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="info"
                  @click="checkDocumentQus"
                  >检查表格</el-button
                >
                <el-button
                  style="margin-left: 10px"
                  size="small"
                  type="success"
                  @click="UploadDocumentQus"
                  >确认上传
                </el-button>
                <template #tip>
                  <div class="el-upload__tip">
                    只能上传xls,xlsx格式的excel文件
                  </div>
                  <div class="el-upload__tip" style="font-size: 20px">
                    {{ currentTimeQus }}
                  </div>
                </template>
              </el-upload>
            </el-col>
            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="warning"
                @click="DownloadDocumentExcelQus"
                >下载表格</el-button
              >
            </el-col>

            <el-col :span="7" style="text-align: center">
              <el-button
                size="small"
                type="danger"
                @click="DownloadDocumentModelQus"
                >下载模板</el-button
              >
            </el-col>
          </el-row>
        </div>
        <!-- 在线查看、编辑excel -->
        <div
          class="excelData"
          style="margin-bottom: 12px"
          v-show="this.excelTableDocQus"
        >
          <el-button
            type="warning"
            plain
            @click="closeCheckDataDocQus"
            style="margin-top: 10px"
            >关闭</el-button
          >
          <el-table
            :data="excelDataDocQus"
            border
            stripe
            style="height: 300px; width: 100%"
            max-height="300px"
          >
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column
              prop="资料名称"
              label="资料名称"
              min-width="150px"
            ></el-table-column>
            <el-table-column prop="资料属性" label="资料属性"></el-table-column>
            <el-table-column prop="问题描述" label="问题描述"></el-table-column>
            <el-table-column prop="已解决" label="已解决"></el-table-column>
            <el-table-column prop="未解决" label="未解决"></el-table-column>
          </el-table>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import XLSX from "xlsx";
import { resolve } from "url";
export default {
  data() {
    return {
      currentTime: "",
      file: "",
      fileListBase: [],
      fileJsonBase: [],
      excelDataBase: [],
      excelTableBase: false,

      fileListJilt: [],
      fileJsonJilt: [],
      excelDataJilt: [],
      excelTableJilt: false,

      fileListPlan: [],
      fileJsonPlan: [],
      excelDataPlan: [],
      excelTablePlan: false,

      fileListExp: [],
      fileJsonExp: [],
      excelDataExp: [],
      excelTableExp: false,

      fileListExpQus: [],
      fileJsonExpQus: [],
      excelDataExpQus: [],
      excelTableExpQus: false,

      fileListPro: [],
      fileJsonPro: [],
      excelDataPro: [],
      excelTablePro: false,

      fileListDoc: [],
      fileJsonDoc: [],
      excelDataDoc: [],
      excelTableDoc: false,

      fileListDocQus: [],
      fileJsonDocQus: [],
      excelDataDocQus: [],
      excelTableDocQus: false,

      isCheckQus: false,

      isCheck: false,

      // arr:['document','experiment','progress','baseList','Jilt'],
      roleName: "",
    };
  },
  mounted() {
    // this.arr = window.sessionStorage.getItem('permisson')
    this.roleName = window.sessionStorage.getItem("roleName");
  },
  methods: {
    OnExceed(files, fileList) {
      this.$message.warning("只能选择1个文件");
    },
    checkExcelFormat(file, fileList) {
      let extension = file.name.substring(file.name.lastIndexOf(".") + 1);
      let size = file.size / 1024 / 1024;
      if (extension !== "xlsx" && extension !== "xls") {
        this.$message.warning("只能上传后缀是.xls或.xlsx的文件");
        return false;
      }
      if (size > 10) {
        this.$message.warning("文件大小不得超过10M");
        return false;
      }
      return true;
    },
    readExcel(file) {
      let reader = new FileReader();
      let result = [];
      reader.onload = function (e) {
        let wb = XLSX.read(e.target.result, {
          type: "binary",
          cellDates: true,
        });
        // 给defval赋值为空的字符串
        const sheetJSONOpts = {
          defval: "",
        };
        wb.SheetNames.forEach((sheetName) => {
          result.push({
            sheetName: sheetName,
            sheet: XLSX.utils.sheet_to_json(
              wb.Sheets[sheetName],
              sheetJSONOpts
            ),
          });
        });
      };
      reader.readAsBinaryString(file.raw);
      this.getCurrentTIme();
      return result;
    },

    readExcelQus(file) {
      let reader = new FileReader();
      let result = [];
      reader.onload = function (e) {
        let wb = XLSX.read(e.target.result, {
          type: "binary",
          cellDates: true,
        });
        // 给defval赋值为空的字符串
        const sheetJSONOpts = {
          defval: "",
        };
        wb.SheetNames.forEach((sheetName) => {
          result.push({
            sheetName: sheetName,
            sheet: XLSX.utils.sheet_to_json(
              wb.Sheets[sheetName],
              sheetJSONOpts
            ),
          });
        });
      };
      reader.readAsBinaryString(file.raw);
      this.getCurrentTImeQus();
      return result;
    },

    //获取当前时间
    getCurrentTIme() {
      let myDate = new Date();
      this.currentTime = myDate.toLocaleString();
    },

    //获取当前时间
    getCurrentTImeQus() {
      let myDate = new Date();
      this.currentTimeQus = myDate.toLocaleString();
    },
    //清空当前时间
    clearCurrentTime() {
      this.currentTime = "";
    },

    clearCurrentTimeQus() {
      this.currentTimeQus = "";
    },

    DownloadExcel(url) {
      let xhr = new XMLHttpRequest();
      xhr.open("get", url);
      xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
      xhr.setRequestHeader("satoken", window.sessionStorage.getItem("satoken"));
      xhr.setRequestHeader(
        "curItemId",
        window.sessionStorage.getItem("activeItem")
      );
      console.log( window.sessionStorage.getItem("activeItem"));
      xhr.responseType = "blob";
      xhr.send("");
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4 && xhr.status === 200) {
          const blob = new Blob([xhr.response]);
          let url = window.URL.createObjectURL(blob);
          //创建一个a标签元素，设置下载属性，点击下载，最后移除该元素
          let link = document.createElement("a");
          link.href = url;
          console.log(url);
          link.style.display = "none";
          //取出下载文件名
          const contentDisposition = xhr.getResponseHeader(
            "Content-Disposition"
          );
          console.log(111,xhr.getResponseHeader(
            "Content-Disposition"
          ));
          if (contentDisposition == null) {
            return alert("表格不存在");
          }
          const downloadFileName = decodeURIComponent(
            contentDisposition.split("=")[1],
            "GBK"
          );
          link.setAttribute("download", downloadFileName);
          link.click();
          window.URL.revokeObjectURL(url);
        }
      };
    },
    //施工计划表
    PlanChange(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListPlan = [];
        this.file = "";
        return false;
      }
      this.file = file.raw;
      this.fileListPlan = fileList;
      this.fileJsonPlan = this.readExcel(file);
    },

    PlamRemove(file, fileList) {
      this.fileListPlan = [];
      this.excelTablePlan = false;
      this.excelDataPlan = [];
      this.clearCurrentTime();
    },

    checkPlan() {
      if (this.file != "") {
        this.excelDataPlan = this.fileJsonPlan[0].sheet;
        console.log(this.excelDataPlan);
        this.excelTablePlan = true;
        this.isCheck = true;
      } else {
        this.$message.warning("请先选择文件");
      }
    },

    async uploadPlan() {
      if (!this.isCheck) {
        this.$message.warning("请先进行表格检查");
        return;
      }
      if (this.file != "") {
        this.$refs.uploadPlan.clearFiles();
        let form = new FormData();
        form.append("file", this.file);
        let curItemId = window.sessionStorage.getItem("activeItem");
        form.append("curItemId", curItemId);
        let url = "TechnicalDirector/uploadPlanExcel";
        let config = {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        };
        const { data: res } = await this.$http.post(url, form, config);
        if (res.code != 200) {
          this.$message.error(res.msg);
        }
        this.$message.success(res.msg);
        this.file = "";
        this.excelTablePlan = false;
        this.isCheck = false;
        this.clearCurrentTime();
      } else {
        this.$message.warning("请先选择文件");
      }
    },

    DownloadPlanExcel() {
      let url =
        this.$http.defaults.baseURL +
        "TechnicalDirector/exportConstructionPlanNewData";
      this.DownloadExcel(url);
    },
    DownloadPlanModel() {
      let url =
        this.$http.defaults.baseURL + "/TechnicalDirector/exportPlanExcelModel";
      this.DownloadExcel(url);
    },

    // 基础清单表
    BaseListChange(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListBase = [];
        this.file = "";
        return false;
      }
      this.file = file.raw;
      this.fileListBase = fileList;
      this.fileJsonBase = this.readExcel(file);
    },
    checkBaseList() {
      if (this.file != "") {
        this.excelDataBase = this.fileJsonBase[0].sheet;
        this.excelTableBase = true;
        let newArr = [];
        let newObj = {};
        let msg = "";
        // this.excelDataBase.forEach(function(item,key) {
        //   console.log(newArr.indexOf(item.项目编号))
        //   if(newArr.indexOf!=-1){
        //     newArr.push(item.项目编号)
        //   }else{
        //     this.excelDataBase.splice(key)
        //   }
        // })
        for (let i = 0; i < this.excelDataBase.length; i++) {
          if (newArr.indexOf(this.excelDataBase[i].项目编号) == -1) {
            newArr.push(this.excelDataBase[i].项目编号);
            newObj[this.excelDataBase[i].项目编号] = this.excelDataBase[i].序号;
          } else {
            msg += `序号${this.excelDataBase[i].序号}与序号${
              newObj[this.excelDataBase[i].项目编号]
            }重复,   `;
          }
        }
        if (msg != "") {
          this.isCheck = false;
          return this.$message({
            type: "warning",
            message: msg,
            duration: 0,
            showClose: true,
          });
        }
        var index = 0;
        var empty = 0;
        var isManzu = this.excelDataBase.every(function (item, i, arr) {
          if (
            item.序号 === "" ||
            item.项目名称 === "" ||
            item.项目特征描述 === "" ||
            item.计量单位 === "" ||
            item.清单工程量 === "" ||
            item.综合单价合价 === "" ||
            item.工程名称 === "" ||
            item.分部工程 === "" ||
            item.分项工程 === "" ||
            item.所属项目部 === "" ||
            item.所属公司 === ""
          ) {
            var keys = Object.keys(item)
            keys.forEach(value =>{
                  if(item[value] ===''){
                    if(value !== '项目简称' && value !=='主材名称' &&  value !=='主材单位' &&  value !=='换算系数' && value !=='主材数量')
                    empty=value;
                  }
                 
            })
            index = i + 1;
            return false;
          } else {
            console.log(item);
            return true;
          }
        });
        if (isManzu) {
          this.isCheck = true;
        } else {
          this.isCheck = false;
          return this.$message({
            type: "warning",
            message:
              "表格数据有误，请检查是否有空项" + index + "行" + ' ' + empty + "不可为空",
            duration: 0,
            showClose: true,
          });
        }
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    BaseListRemove(file, fileList) {
      this.fileListBase = [];
      this.excelTableBase = false;
      this.excelDataBase = [];
      this.clearCurrentTime();
    },
    async uploadBaseList() {
      if (!this.isCheck) {
        this.$message.warning("请先进行表格检查");
        return;
      }
      if (this.file != "") {
        this.$refs.uploadBaseList.clearFiles();
        let form = new FormData();
        form.append("file", this.file);
        console.log(this.file);
        let curItemId = window.sessionStorage.getItem("activeItem");
        form.append("curItemId", curItemId);
        let url = "contractor/uploadBaseExcel";
        let config = {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        };
        const { data: res } = await this.$http.post(url, form, config);
        if (res.code != 200) {
          this.$message.error(res.msg);
        }
        this.$message.success(res.msg);
        this.file = "";
        this.excelTableBase = false;
        this.isCheck = false;
        this.clearCurrentTime();
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DownloadBaseListModel() {
      let url = this.$http.defaults.baseURL + "contractor/exportBaseExcelModel";
      this.DownloadExcel(url);
    },
    DownloadBaseListExcel() {
      let url = this.$http.defaults.baseURL + "/contractor/exportBaseListExcel";
      this.DownloadExcel(url);
    },
    // 参数表 
    Downloadparameter(){
       let url = this.$http.defaults.baseURL + "/contractor/exportParameterExcel";
      this.DownloadExcel(url);
    },
    // 甩项工程量
    JiltChange(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListJilt = [];
        this.file = "";
        return false;
      }
      this.file = file.raw;
      this.fileListJilt = fileList;
      this.fileJsonJilt = this.readExcel(file);
    },
    checkJilt() {
      if (this.file != "") {
        this.excelDataJilt = this.fileJsonJilt[0].sheet;
        this.excelTableJilt = true;
        var index = 0;
        var isManzu = this.excelDataJilt.every(function (item, i, arr) {
          if (
            item.项目编号 === "" ||
            item.甩项工程量 === "" ||
            item.甩项原因 === ""
          ) {
            index = i + 1;
            return false;
          } else {
            return true;
          }
        });
        if (isManzu) {
          this.isCheck = true;
        } else {
          this.isCheck = false;
          return this.$message.warning(
            "项目编号、甩项工程量、甩项原因不能为空,请检查第" + index + "行"
          );
        }
      } else {
        this.$message.warning("请先选择文件");
      }
    },

    JiltRemove(file, fileList) {
      this.fileListJilt = [];
      this.excelTableJilt = false;
      this.excelDataJilt = [];
      this.clearCurrentTime();
    },
    async uploadJilt() {
      if (!this.isCheck) {
        this.$message.warning("请先进行表格检查");
        return;
      }
      if (this.file != "") {
        this.$refs.uploadJilt.clearFiles();
        let form = new FormData();
        form.append("file", this.file);
        let curItemId = window.sessionStorage.getItem("activeItem");
        form.append("curItemId", curItemId);
        let url = "contractor/uploadJiltExcel";
        let config = {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        };
        const { data: res } = await this.$http.post(url, form, config);
        if (res.code != 200) {
          this.$message.error(res.msg);
        }
        this.$message.success(res.msg);
        this.file = "";
        this.excelTableJilt = false;
        this.isCheck = false;
        this.clearCurrentTime();
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DownloadJiltModel() {
      let url = this.$http.defaults.baseURL + "contractor/exportJiltExcelModel";
      this.DownloadExcel(url);
    },
    DownloadJiltExcel() {
      let url =
        this.$http.defaults.baseURL + "/contractor/exportJiltQuantityExcel";
      this.DownloadExcel(url);
    },
    // 进度表
    ProgressChange(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListPro = [];
        this.file = "";
        return false;
      }
      this.file = file.raw;
      this.fileListPro = fileList;
      this.fileJsonPro = this.readExcel(file);
    },
    checkProgress() {
      console.log("dadsadasdsadas");
      if (this.file != "") {
        this.excelDataPro = this.fileJsonPro[0].sheet;
        this.excelTablePro = true;
        var index = 0;
        var isManzu = this.excelDataPro.every(function (item, i, arr) {
          if (
            item.起桩号 === "" ||
            item.止桩号 === "" ||
            item.本次完成工程量 === "" ||
            item.项目编号 === ""
          ) {
            index = i + 1;
            return false;
          } else {
            return true;
          }
        });
        if (isManzu) {
          console.log(isManzu);
          this.isCheck = true;
        } else {
          this.isCheck = false;
          return this.$message({
            type: "warning",
            message: `有空项，请检查第${index}行，起桩号、止桩号、本次完成工程量和项目编号不能为空`,
            duration: 0,
            showClose: true,
          });
        }
      } else {
        this.$message.warning("请先选择文件adasdsadadsad");
      }
    },
    ProgressRemove(file, fileList) {
      this.fileListPro = [];
      this.excelTablePro = false;
      this.excelDataPro = [];
      this.clearCurrentTime();
    },
    ProgressChange(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListPro = [];
        this.file = "";
        return false;
      }
      this.file = file.raw;
      this.fileListPro = fileList;
      this.fileJsonPro = this.readExcel(file);
    },
    checkProgress() {
      if (this.file != "") {
        this.excelDataPro = this.fileJsonPro[0].sheet;
        this.excelTablePro = true;
        this.isCheck = true;
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    ProgressRemove(file, fileList) {
      this.fileListPro = [];
      this.excelTablePro = false;
      this.excelDataPro = [];
    },
    async uploadProgress() {
      if (!this.isCheck) {
        this.$message.warning("请先进行表格检查");
        return;
      }
      if (this.file != "") {
        this.$refs.uploadProgress.clearFiles();
        let form = new FormData();
        form.append("file", this.file);
        let curItemId = window.sessionStorage.getItem("activeItem");
        // let curItemId = 3;
        form.append("curItemId", curItemId);
        console.log("sads");
        let url = "progresser/uploadProgressExcel";
        let config = {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        };
        const { data: res } = await this.$http.post(url, form, config);
        if (res.code != 200) {
          this.$message.error(res.msg);
        }
        this.$message.success(res.msg);
        this.file = "";
        this.excelTablePro = false;
        this.isCheck = false;
        this.clearCurrentTime();
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DownloadProgressModel() {
      let url =
        this.$http.defaults.baseURL + "progresser/exportProgressExcelModel"; //---------------
      this.DownloadExcel(url);
    },
    DownloadProgressExcel() {
      let url = this.$http.defaults.baseURL + "progresser/exportProgressExcel";
      this.DownloadExcel(url);
    },

    // 试验检测表
    ExperimentChange(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListExp = [];
        this.file = "";
        return false;
      }
      this.file = file.raw;
      this.fileListExp = fileList;
      this.fileJsonExp = this.readExcel(file);
    },
    checkExperiment() {
      if (this.file != "") {
        this.excelDataExp = this.fileJsonExp[0].sheet;
        console.log("sadas", this.excelDataExp);
        this.excelTableExp = true;
        var index = 0;
        var isManzu = this.excelDataExp.every(function (item, i, arr) {
          if (
            item.工程名称 === "" ||
            item.材料及实体名称 === "" ||
            item.检测项目 === "" ||
            item.检测频率 === "" ||
            item.说明 === "" ||
            item.工程量单位 === "" ||
            item.清单工程量 === "" ||
            item.现场进度工程量 === "" ||
            item.检测单位 === "" ||
            item.检测系数 === "" ||
            item.实际检测数量 === "" ||
            item.已取检测报告数量 === "" ||
            item.检测合格数量 === ""
          ) {
            index = i + 1;
            return false;
          } else {
            return true;
          }
        });
        if (isManzu) {
          this.isCheck = true;
        } else {
          this.isCheck = false;
          return this.$message({
            type: "warning",
            message: `有空项，请检查第${index}行`,
            duration: 0,
            showClose: true,
          });
        }
      } else {
        this.$message({
          type: "warning",
          message: `请先选择文件`,
          duration: 0,
          showClose: true,
        });
      }
    },
    ExperimentRemove(file, fileList) {
      this.fileListExp = [];
      this.excelTableExp = false;
      this.excelDataExp = [];
      this.clearCurrentTime();
    },
    async uploadExperiment() {
      if (!this.isCheck) {
        this.$message.warning("请先进行表格检查");
        return;
      }
      if (this.file != "") {
        this.$refs.uploadExperiment.clearFiles();
        let form = new FormData();
        form.append("file", this.file);
        let curItemId = window.sessionStorage.getItem("activeItem");
        form.append("curItemId", curItemId);
        let url = "experimenter/uploadExperimentExcel";
        let config = {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        };
        const { data: res } = await this.$http.post(url, form, config);
        if (res.code != 200) {
          this.$message.error(res.msg);
        }
        this.$message.success(res.msg);
        this.file = "";
        this.excelTableExp = false;
        this.isCheck = false;
        this.clearCurrentTime();
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DownloadExperimentModel() {
      let url =
        this.$http.defaults.baseURL + "experimenter/exportExperimentExcelModel";
      this.DownloadExcel(url);
    },
    DownloadExperimentExcel() {
      let url =
        this.$http.defaults.baseURL + "experimenter/exportExperimentExcel";
      this.DownloadExcel(url);
    },

    // 试验检测不合格表
    ExperimentChangeQus(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListExpQus = [];
        this.fileQus = "";
        return false;
      }
      this.fileQus = file.raw;
      this.fileListExpQus = fileList;
      this.fileJsonExpQus = this.readExcelQus(file);
    },
    checkExperimentQus() {
      if (this.fileQus != "") {
        this.excelDataExpQus = this.fileJsonExpQus[0].sheet;
        console.log("sadas", this.excelDataExp);
        this.excelTableExpQus = true;
        let index = 0;
        let isManzu = this.excelDataExpQus.every(function (item, i, arr) {
          if (item.工程名称 === "" || item.委托单编号 === "") {
            index = i + 1;
            return false;
          } else {
            return true;
          }
        });
        if (isManzu) {
          this.isCheckQus = true;
        } else {
          this.isCheckQus = false;
          return this.$message.warning(
            "有空项，请检查第" +
              index +
              "行,清单应检数量或者进度应检数量，其余可为空"
          );
        }
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    ExperimentRemoveQus(file, fileList) {
      this.fileListExpQus = [];
      this.excelTableExpQus = false;
      this.excelDataExpQus = [];
      this.clearCurrentTimeQus();
    },
    async uploadExperimentQus() {
      if (!this.isCheckQus) {
        this.$message.warning("请先进行表格检查");
        return;
      }
      if (this.fileQus != "") {
        this.$refs.uploadExperimentQus.clearFiles();
        let form = new FormData();
        form.append("file", this.fileQus);
        let curItemId = window.sessionStorage.getItem("activeItem");
        form.append("curItemId", curItemId);
        let url = "/experimenter/uploadNoPassExcel";
        let config = {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        };
        const { data: res } = await this.$http.post(url, form, config);
        if (res.code != 200) {
          this.$message.err(res.msg);
        }
        this.$message.success(res.msg);
        this.fileQus = "";
        this.excelTableExpQus = false;
        this.isCheckQus = false;
        this.clearCurrentTimeQus();
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DownloadExperimentModelQus() {
      console.log(222);
      let url =
        this.$http.defaults.baseURL + "experimenter/exportNoPassExcelModel";
      this.DownloadExcel(url);
    },
    DownloadExperimentExcelQus() {
      let url = this.$http.defaults.baseURL + "experimenter/exportNoPassExcel";
      this.DownloadExcel(url);
    },

    // 资料表
    DocumentChange(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListDoc = [];
        this.file = "";
        return false;
      }
      this.file = file.raw;
      this.fileListDoc = fileList;
      this.fileJsonDoc = this.readExcel(file);
    },
    checkDocument() {
      if (this.file != "") {
        this.excelDataDoc = this.fileJsonDoc[0].sheet;
        this.excelTableDoc = true;
        var index = 0;
        var isManzu = this.excelDataDoc.every(function (item, i, arr) {
          if (
            item.册数 === "" ||
            item.文件材料说明 === "" ||
            item.资料说明 === "" ||
            item.资料完成情况说明 === "" ||
            item.总数 === ""
          ) {
            index = i + 1;
            return false;
          } else {
            return true;
          }
        });
        var satisfy = this.excelDataDoc.every(function (item, i, arr) {
          if (
            parseInt(item.编制数) > parseInt(item.总数) ||
            parseInt(item.编制数) < parseInt(item.监理签认数) ||
            parseInt(item.编制数) < parseInt(item.设计签认数) ||
            parseInt(item.编制数) < parseInt(item.建设单位签认数)
          ) {
            return false;
          } else {
            return true;
          }
        });
        if (isManzu) {
          if (satisfy) {
            this.isCheck = true;
          } else {
            return this.$message.warning(
              "表格数据有误，请检查是否符合规则： 监理签认数<编制数<总数，设计签认数<编制数，建设单位签认数<编制数"
            );
          }
        } else {
          this.isCheck = false;
          return this.$message.warning(
            "有空项，请检查,提醒：第" + index + "行"
          );
        }
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DocumentRemove(file, fileList) {
      this.fileListDoc = [];
      this.excelTableDoc = false;
      this.excelDataDoc = [];
      this.clearCurrentTime();
    },
    async UploadDocument() {
      if (!this.isCheck) {
        this.$message.warning("请先进行表格检查");
        return;
      }
      if (this.file != "") {
        this.$refs.uploadDocument.clearFiles();
        let form = new FormData();
        form.append("file", this.file);
        let curItemId = window.sessionStorage.getItem("activeItem");
        form.append("curItemId", curItemId);
        let url = "documenter/uploadDocumentExcel";
        let config = {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        };
        const { data: res } = await this.$http.post(url, form, config);
        if (res.code != 200) {
          this.$message.error(res.msg);
        }
        this.$message.success(res.msg);
        this.file = "";
        this.excelTableDoc = false;
        this.isCheck = false;
        this.clearCurrentTime();
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DownloadDocumentModel() {
      let url =
        this.$http.defaults.baseURL + "documenter/exportDocumentExcelModel";
      this.DownloadExcel(url);
    },
    DownloadDocumentExcel() {
      let url = this.$http.defaults.baseURL + "documenter/exportDocumentExcel";
      this.DownloadExcel(url);
    },

    // 资料问题表 Qus
    DocumentChangeQus(file, fileList) {
      if (!this.checkExcelFormat(file, fileList)) {
        this.fileListDocQus = [];
        this.fileQus = "";
        return false;
      }
      this.fileQus = file.raw;
      this.fileListDocQus = fileList;
      this.fileJsonDocQus = this.readExcelQus(file);
    },
    checkDocumentQus() {
      if (this.fileQus != "") {
        this.excelDataDocQus = this.fileJsonDocQus[0].sheet;
        this.excelTableDocQus = true;
        let index = 0;
        let isManzu = this.excelDataDocQus.every(function (item, i, arr) {
          if (
            item.资料名称 === "" ||
            item.资料属性 === "" ||
            item.问题描述 === "" ||
            item.已解决 === "" ||
            item.未解决 === ""
          ) {
            index = i + 1;
            return false;
          } else {
            return true;
          }
        });
        if (isManzu) {
          this.isCheckQus = true;
        } else {
          this.isCheckQus = false;
          return this.$message.warning(
            "有空项，请检查,提醒：第" + index + "行"
          );
        }
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DocumentRemoveQus(file, fileList) {
      this.fileListDocQus = [];
      this.excelTableDocQus = false;
      this.excelDataDocQus = [];
      this.clearCurrentTimeQus();
    },

    async UploadDocumentQus() {
      if (!this.isCheckQus) {
        this.$message.warning("请先进行表格检查");
        return;
      }
      if (this.fileQus != "") {
        this.$refs.uploadDocumentQus.clearFiles();
        let form = new FormData();
        form.append("file", this.fileQus);
        let curItemId = window.sessionStorage.getItem("activeItem");
        form.append("curItemId", curItemId);
        let url = "/documenter/uploadProblemDocumentExcel";
        let config = {
          headers: {
            "Content-Type": "multipart/form-data",
          },
        };
        const { data: res } = await this.$http.post(url, form, config);
        if (res.code != 200) {
          this.$message.err(res.msg);
        }
        this.$message.success(res.msg);
        this.fileQus = "";
        this.excelTableDocQus = false;
        this.isCheckQus = false;
        this.clearCurrentTimeQus();
      } else {
        this.$message.warning("请先选择文件");
      }
    },
    DownloadDocumentModelQus() {
      let url =
        this.$http.defaults.baseURL +
        "documenter/exportProblemDocumentExcelModel";
      this.DownloadExcel(url);
    },
    DownloadDocumentExcelQus() {
      let url =
        this.$http.defaults.baseURL + "documenter/exportProblemDocumentExcel";
      this.DownloadExcel(url);
    },

    //关闭查看表格框
    //甩项
    closeCheckJilt() {
      this.excelTableJilt = !this.excelTableJilt;
    },
    //资料
    closeCheckDataDoc() {
      this.excelTableDoc = !this.excelTableDoc;
    },
    //资料问题表
    closeCheckDataDocQus() {
      this.excelTableDocQus = !this.excelTableDocQus;
    },
    //基本清单表
    closeCheckDataBase() {
      this.excelTableBase = !this.excelTableBase;
    },
    //实验
    closeCheckDataExp() {
      this.excelTableExp = !this.excelTableExp;
    },

    //实验
    closeCheckDataExpQus() {
      this.excelTableExpQus = !this.excelTableExpQus;
    },
    //进度
    closeCheckDataPro() {
      this.excelTablePro = !this.excelTablePro;
    },
    //施工
    closeCheckDataPlan() {
      this.excelTablePlan = !this.excelTablePlan;
    },
  },
};
</script>

<style lang="less" scoped>
.excel {
  width: 100%;
  height: 150px;
  border-bottom: 1px solid #eee;
  margin-bottom: 15px;

  .title {
    font-size: 14px;
    color: #666;
    display: block;
    margin-bottom: 10px;
  }
}
</style>
